﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class web_Controls_Ctrl_vl_top_sub_banner : System.Web.UI.UserControl
{
    Common comm = new Common();
    public DataTable dtt;
    public string sBanner = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        dtt = comm.getDataTable("select * from HeThong_config where id=1");
        if (dtt.Rows.Count > 0)
        {
            if (!(String.IsNullOrEmpty(dtt.Rows[0]["banner_path"].ToString())))
            {
                //sBanner = getViewFlash("100%", "200px", "../../"+dtt.Rows[0]["banner_path"].ToString());
            }
        }
        if (!Page.IsPostBack)
        {
            LoadData();
            
        }
    }
    private string getViewFlash(string width, string height, string url)
    {
        string[] kiemtra = url.Split('.');
        string chuoimatna = "jpg,jpeg,png,bmp,gif";
        string fileType = kiemtra.GetValue(kiemtra.Length - 1).ToString().ToLower();
        if (chuoimatna.Contains(fileType) == true) //neu dung nghĩa là đây là file ảnh

            return "<a href='Default.aspx'><img src='" + url + "' height='" + height + "' width='" + width + "' /></a>";
        else
            return " " +
            "<object  width='1000px' height='235px' type='application/x-shockwave-flash' data='" + url +
            "'><param name='movie' value='" + url + "'/><param name='WMode' value='Transparent'/></object>";
    }
    void LoadData()
    {
        rpt_top_mn_gt.DataSource = comm.ExeceuteDataset("select * from TinTuc_loai_tin_tuc where ma_cha = 'gioithieu' and kich_hoat = 1 order by ngay_tao desc");
        rpt_top_mn_gt.DataBind();
        rpt_top_mn_sgd.DataSource = comm.ExeceuteDataset("select * from TinTuc_loai_tin_tuc where ma_cha = 'sgd' and kich_hoat = 1 order by ngay_tao desc");
        rpt_top_mn_sgd.DataBind();
        rpt_top_mn_bhtn.DataSource = comm.ExeceuteDataset("select * from TinTuc_loai_tin_tuc where ma_cha = 'bhtn' and kich_hoat = 1 order by ngay_tao desc");
        rpt_top_mn_bhtn.DataBind();
    }
}
